<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.12"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>emp-toolkit: /Users/wangxiao/git/emp-toolkit/emp-tool/utils/utils_ec.h Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
</script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><img alt="Logo" src="logo-full-doxygen.png"/></td>
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">emp-toolkit
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.12 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
$(document).ready(function(){initNavTree('utils__ec_8h_source.html','');});
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="headertitle">
<div class="title">utils_ec.h</div>  </div>
</div><!--header-->
<div class="contents">
<a href="utils__ec_8h.html">Go to the documentation of this file.</a><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;<span class="preprocessor">#ifndef UTILS_EC_H__</span></div><div class="line"><a name="l00002"></a><span class="lineno">    2</span>&#160;<span class="preprocessor">#define UTILS_EC_H__</span></div><div class="line"><a name="l00003"></a><span class="lineno">    3</span>&#160;<span class="keyword">extern</span> <span class="stringliteral">&quot;C&quot;</span> {</div><div class="line"><a name="l00004"></a><span class="lineno">    4</span>&#160;<span class="preprocessor">#include &lt;relic/relic.h&gt;</span></div><div class="line"><a name="l00005"></a><span class="lineno">    5</span>&#160;}</div><div class="line"><a name="l00006"></a><span class="lineno">    6</span>&#160;<span class="preprocessor">#include &quot;<a class="code" href="utils_2block_8h.html">block.h</a>&quot;</span></div><div class="line"><a name="l00007"></a><span class="lineno">    7</span>&#160;</div><div class="line"><a name="l00008"></a><span class="lineno">    8</span>&#160;<span class="preprocessor">#include &quot;<a class="code" href="hash_8h.html">hash.h</a>&quot;</span></div><div class="line"><a name="l00009"></a><span class="lineno"><a class="line" href="utils__ec_8h.html#af693362576a030d027a217a609106008">    9</a></span>&#160;<span class="preprocessor">#define ECC_PACK false</span></div><div class="line"><a name="l00010"></a><span class="lineno"><a class="line" href="utils__ec_8h.html#a1c3815a8647e6c0fd8e19b2107f2e4fd">   10</a></span>&#160;<span class="preprocessor">#define BIT_LEN 128</span></div><div class="line"><a name="l00011"></a><span class="lineno"><a class="line" href="utils__ec_8h.html#a68ab140a6106405e8b0f0eccf4e1b113">   11</a></span>&#160;<span class="preprocessor">#define EB_SIZE 65</span></div><div class="line"><a name="l00012"></a><span class="lineno">   12</span>&#160;</div><div class="line"><a name="l00013"></a><span class="lineno">   13</span>&#160;</div><div class="line"><a name="l00014"></a><span class="lineno"><a class="line" href="utils__ec_8h.html#afcde481e82d4efeed62b66b9f12ccbd9">   14</a></span>&#160;<span class="keyword">typedef</span> eb_t <a class="code" href="utils__ec_8h.html#afcde481e82d4efeed62b66b9f12ccbd9">eb_tpl</a>[2];</div><div class="line"><a name="l00015"></a><span class="lineno"><a class="line" href="utils__ec_8h.html#a09cbcd1b9548176fce4883fa31bbd17f">   15</a></span>&#160;<span class="keyword">typedef</span> bn_t <a class="code" href="utils__ec_8h.html#a09cbcd1b9548176fce4883fa31bbd17f">bn_tpl</a>[2];</div><div class="line"><a name="l00016"></a><span class="lineno">   16</span>&#160;</div><div class="line"><a name="l00017"></a><span class="lineno"><a class="line" href="utils__ec_8h.html#ad36cbdf5b483e6cee6b95d7ad6adfbff">   17</a></span>&#160;<span class="preprocessor">#define __batch(func, ...)\</span></div><div class="line"><a name="l00018"></a><span class="lineno">   18</span>&#160;<span class="preprocessor">    template &lt;typename H, typename... T&gt; void func##l(H p, T... t) {\</span></div><div class="line"><a name="l00019"></a><span class="lineno">   19</span>&#160;<span class="preprocessor">        func(p,##__VA_ARGS__);\</span></div><div class="line"><a name="l00020"></a><span class="lineno">   20</span>&#160;<span class="preprocessor">        func##l(t...);\</span></div><div class="line"><a name="l00021"></a><span class="lineno">   21</span>&#160;<span class="preprocessor">    }\</span></div><div class="line"><a name="l00022"></a><span class="lineno">   22</span>&#160;<span class="preprocessor">    template &lt;typename H&gt; void func##l(H p) {\</span></div><div class="line"><a name="l00023"></a><span class="lineno">   23</span>&#160;<span class="preprocessor">        func(p,##__VA_ARGS__);\</span></div><div class="line"><a name="l00024"></a><span class="lineno">   24</span>&#160;<span class="preprocessor">    }</span></div><div class="line"><a name="l00025"></a><span class="lineno">   25</span>&#160;</div><div class="line"><a name="l00026"></a><span class="lineno">   26</span>&#160;<a class="code" href="utils__ec_8h.html#ad36cbdf5b483e6cee6b95d7ad6adfbff">__batch</a>(eb_new);</div><div class="line"><a name="l00027"></a><span class="lineno">   27</span>&#160;<a class="code" href="utils__ec_8h.html#ad36cbdf5b483e6cee6b95d7ad6adfbff">__batch</a>(eb_free);</div><div class="line"><a name="l00028"></a><span class="lineno">   28</span>&#160;<a class="code" href="utils__ec_8h.html#ad36cbdf5b483e6cee6b95d7ad6adfbff">__batch</a>(bn_new);</div><div class="line"><a name="l00029"></a><span class="lineno">   29</span>&#160;<a class="code" href="utils__ec_8h.html#ad36cbdf5b483e6cee6b95d7ad6adfbff">__batch</a>(bn_free);</div><div class="line"><a name="l00030"></a><span class="lineno">   30</span>&#160;</div><div class="line"><a name="l00031"></a><span class="lineno"><a class="line" href="utils__ec_8h.html#adad3129fffb7029d84a90dd993eb272d">   31</a></span>&#160;<span class="preprocessor">#define __batch2(func)\</span></div><div class="line"><a name="l00032"></a><span class="lineno">   32</span>&#160;<span class="preprocessor">template &lt;typename H1, typename H2, typename H3&gt; void func##_norm(H1 h1, H2 h2, H3 h3) {\</span></div><div class="line"><a name="l00033"></a><span class="lineno">   33</span>&#160;<span class="preprocessor">    func(h1, h2, h3);\</span></div><div class="line"><a name="l00034"></a><span class="lineno">   34</span>&#160;<span class="preprocessor">    eb_norm(h1, h1);\</span></div><div class="line"><a name="l00035"></a><span class="lineno">   35</span>&#160;<span class="preprocessor">}\</span></div><div class="line"><a name="l00036"></a><span class="lineno">   36</span>&#160;<span class="preprocessor"></span></div><div class="line"><a name="l00037"></a><span class="lineno">   37</span>&#160;<a class="code" href="utils__ec_8h.html#adad3129fffb7029d84a90dd993eb272d">__batch2</a>(eb_mul);</div><div class="line"><a name="l00038"></a><span class="lineno">   38</span>&#160;<a class="code" href="utils__ec_8h.html#adad3129fffb7029d84a90dd993eb272d">__batch2</a>(eb_mul_fix);</div><div class="line"><a name="l00039"></a><span class="lineno">   39</span>&#160;<a class="code" href="utils__ec_8h.html#adad3129fffb7029d84a90dd993eb272d">__batch2</a>(eb_sub);</div><div class="line"><a name="l00040"></a><span class="lineno">   40</span>&#160;<a class="code" href="utils__ec_8h.html#adad3129fffb7029d84a90dd993eb272d">__batch2</a>(eb_add);</div><div class="line"><a name="l00041"></a><span class="lineno">   41</span>&#160;</div><div class="line"><a name="l00042"></a><span class="lineno"><a class="line" href="utils__ec_8h.html#a7294001caef3ac81942d0e7c4415973c">   42</a></span>&#160;<span class="preprocessor">#define __batch3(func)\</span></div><div class="line"><a name="l00043"></a><span class="lineno">   43</span>&#160;<span class="preprocessor">template &lt;typename H1, typename H2, typename H3, typename H4&gt; void func##_mod(H1 h1, H2 h2, H3 h3, H4 h4) {\</span></div><div class="line"><a name="l00044"></a><span class="lineno">   44</span>&#160;<span class="preprocessor">    func(h1, h2, h3);\</span></div><div class="line"><a name="l00045"></a><span class="lineno">   45</span>&#160;<span class="preprocessor">    bn_mod(h1, h1, h4);\</span></div><div class="line"><a name="l00046"></a><span class="lineno">   46</span>&#160;<span class="preprocessor">}\</span></div><div class="line"><a name="l00047"></a><span class="lineno">   47</span>&#160;<span class="preprocessor"></span></div><div class="line"><a name="l00048"></a><span class="lineno">   48</span>&#160;<a class="code" href="utils__ec_8h.html#a7294001caef3ac81942d0e7c4415973c">__batch3</a>(bn_mul);</div><div class="line"><a name="l00049"></a><span class="lineno">   49</span>&#160;<a class="code" href="utils__ec_8h.html#a7294001caef3ac81942d0e7c4415973c">__batch3</a>(bn_sub);</div><div class="line"><a name="l00050"></a><span class="lineno">   50</span>&#160;<a class="code" href="utils__ec_8h.html#a7294001caef3ac81942d0e7c4415973c">__batch3</a>(bn_add);</div><div class="line"><a name="l00051"></a><span class="lineno">   51</span>&#160;</div><div class="line"><a name="l00052"></a><span class="lineno">   52</span>&#160;<span class="keywordtype">void</span> <a class="code" href="utils__ec_8h.html#a8ed7eb78162c7568c1884dffe014c37e">bn_to_block</a>(<a class="code" href="garble_2block_8h.html#a65abbf31b0a30290189cdb5059b5f785">block</a> * b, <span class="keyword">const</span> bn_t bn);</div><div class="line"><a name="l00053"></a><span class="lineno">   53</span>&#160;<span class="keywordtype">void</span> <a class="code" href="utils__ec_8h.html#a40171df044fc78651ebe5f1aa9e9fa60">block_to_bn</a>(bn_t bn, <span class="keyword">const</span> <a class="code" href="garble_2block_8h.html#a65abbf31b0a30290189cdb5059b5f785">block</a> * b);</div><div class="line"><a name="l00054"></a><span class="lineno">   54</span>&#160;<span class="keyword">static</span> <span class="keywordtype">bool</span> initialized = <span class="keyword">false</span>;</div><div class="line"><a name="l00055"></a><span class="lineno">   55</span>&#160;<span class="keywordtype">void</span> <a class="code" href="utils__ec_8h.html#a782fdb3f06e7f49116d014d4a583b19f">initialize_relic</a>();</div><div class="line"><a name="l00056"></a><span class="lineno">   56</span>&#160;</div><div class="line"><a name="l00057"></a><span class="lineno">   57</span>&#160;<a class="code" href="garble_2block_8h.html#a65abbf31b0a30290189cdb5059b5f785">block</a> <a class="code" href="utils__ec_8h.html#ae5e3f2827ebda785cd770866307cc26d">KDF</a>(eb_t in);</div><div class="line"><a name="l00058"></a><span class="lineno">   58</span>&#160;<span class="preprocessor">#include &quot;<a class="code" href="utils__ec_8hpp.html">utils_ec.hpp</a>&quot;</span></div><div class="line"><a name="l00059"></a><span class="lineno">   59</span>&#160;<span class="preprocessor">#endif// UTILS_EC_H__</span></div><div class="ttc" id="utils__ec_8hpp_html"><div class="ttname"><a href="utils__ec_8hpp.html">utils_ec.hpp</a></div></div>
<div class="ttc" id="utils__ec_8h_html_ad36cbdf5b483e6cee6b95d7ad6adfbff"><div class="ttname"><a href="utils__ec_8h.html#ad36cbdf5b483e6cee6b95d7ad6adfbff">__batch</a></div><div class="ttdeci">#define __batch(func,...)</div><div class="ttdef"><b>Definition:</b> utils_ec.h:17</div></div>
<div class="ttc" id="garble_2block_8h_html_a65abbf31b0a30290189cdb5059b5f785"><div class="ttname"><a href="garble_2block_8h.html#a65abbf31b0a30290189cdb5059b5f785">block</a></div><div class="ttdeci">__m128i block</div><div class="ttdef"><b>Definition:</b> block.h:8</div></div>
<div class="ttc" id="utils__ec_8h_html_a7294001caef3ac81942d0e7c4415973c"><div class="ttname"><a href="utils__ec_8h.html#a7294001caef3ac81942d0e7c4415973c">__batch3</a></div><div class="ttdeci">#define __batch3(func)</div><div class="ttdef"><b>Definition:</b> utils_ec.h:42</div></div>
<div class="ttc" id="hash_8h_html"><div class="ttname"><a href="hash_8h.html">hash.h</a></div></div>
<div class="ttc" id="utils__ec_8h_html_afcde481e82d4efeed62b66b9f12ccbd9"><div class="ttname"><a href="utils__ec_8h.html#afcde481e82d4efeed62b66b9f12ccbd9">eb_tpl</a></div><div class="ttdeci">eb_t eb_tpl[2]</div><div class="ttdef"><b>Definition:</b> utils_ec.h:14</div></div>
<div class="ttc" id="utils__ec_8h_html_a09cbcd1b9548176fce4883fa31bbd17f"><div class="ttname"><a href="utils__ec_8h.html#a09cbcd1b9548176fce4883fa31bbd17f">bn_tpl</a></div><div class="ttdeci">bn_t bn_tpl[2]</div><div class="ttdef"><b>Definition:</b> utils_ec.h:15</div></div>
<div class="ttc" id="utils__ec_8h_html_ae5e3f2827ebda785cd770866307cc26d"><div class="ttname"><a href="utils__ec_8h.html#ae5e3f2827ebda785cd770866307cc26d">KDF</a></div><div class="ttdeci">block KDF(eb_t in)</div><div class="ttdef"><b>Definition:</b> utils_ec.hpp:20</div></div>
<div class="ttc" id="utils__ec_8h_html_a782fdb3f06e7f49116d014d4a583b19f"><div class="ttname"><a href="utils__ec_8h.html#a782fdb3f06e7f49116d014d4a583b19f">initialize_relic</a></div><div class="ttdeci">void initialize_relic()</div><div class="ttdef"><b>Definition:</b> utils_ec.hpp:8</div></div>
<div class="ttc" id="utils__ec_8h_html_a40171df044fc78651ebe5f1aa9e9fa60"><div class="ttname"><a href="utils__ec_8h.html#a40171df044fc78651ebe5f1aa9e9fa60">block_to_bn</a></div><div class="ttdeci">void block_to_bn(bn_t bn, const block *b)</div><div class="ttdef"><b>Definition:</b> utils_ec.hpp:5</div></div>
<div class="ttc" id="utils__ec_8h_html_adad3129fffb7029d84a90dd993eb272d"><div class="ttname"><a href="utils__ec_8h.html#adad3129fffb7029d84a90dd993eb272d">__batch2</a></div><div class="ttdeci">#define __batch2(func)</div><div class="ttdef"><b>Definition:</b> utils_ec.h:31</div></div>
<div class="ttc" id="utils_2block_8h_html"><div class="ttname"><a href="utils_2block_8h.html">block.h</a></div></div>
<div class="ttc" id="utils__ec_8h_html_a8ed7eb78162c7568c1884dffe014c37e"><div class="ttname"><a href="utils__ec_8h.html#a8ed7eb78162c7568c1884dffe014c37e">bn_to_block</a></div><div class="ttdeci">void bn_to_block(block *b, const bn_t bn)</div><div class="ttdef"><b>Definition:</b> utils_ec.hpp:1</div></div>
</div><!-- fragment --></div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="navelem"><a class="el" href="dir_eec959d81771dc8b1a750b834e1341eb.html">emp-tool</a></li><li class="navelem"><a class="el" href="dir_363cbed62d1567d90b8cbb6bda69428f.html">utils</a></li><li class="navelem"><a class="el" href="utils__ec_8h.html">utils_ec.h</a></li>
    <li class="footer">Generated by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.12 </li>
  </ul>
</div>
</body>
</html>
